package com.training.java.core.homework04;

// Player is Abstract base class, containing only one Abstract method doPractice(). Since the general
// exercise routine for players of many sports may be same, doExercise() method is implemented here.
// If necessary, the player of a specific may override it.
// However, the practice routine may differ from sport to sport. So, doPractice() is coded here as
// Abstract method. In SoccerPlayer class, doPractice() is implemented.
public abstract class Player {

	private double height;
	private double weight;
	private int fitness; // A numerical value in the scale of 10
	private double hours;

	// Methods
	public Player(double height, double weight, int fitness) {

		if (height < 3) {
			this.height = 3;
		} else {
			this.height = height;
		}

		this.weight = weight;

		if (fitness < 0) {
			this.fitness = 0;
		} else if (fitness > 10) {
			this.fitness = 10;
		} else {
			this.fitness = fitness;
		}
	}

	public void doExercise(double hours) {
		this.weight = (this.weight * 0.9) / hours;
		this.fitness = (int) (this.fitness * hours * 0.85);
	}

	// Getters
	public double getHeight() {
		return height;
	}

	public double getWeight() {
		return weight;
	}

	public int getFitness() {
		return fitness;
	}

	public double getHours() {
		return hours;
	}

	// Abstract classes
	abstract void doPractice(double hours);
}
